a tool for shared writing and social publishing
at feature/recommend 76 lines 2.7 kB view raw
1"use client"; 2import { useUIState } from "src/useUIState"; 3import { Footer as ActionFooter } from "components/ActionBar/Footer"; 4import { Media } from "components/Media"; 5import { ThemePopover } from "components/ThemeManager/ThemeSetter"; 6import { Toolbar } from "components/Toolbar"; 7import { ShareOptions } from "app/[leaflet_id]/actions/ShareOptions"; 8import { HomeButton } from "app/[leaflet_id]/actions/HomeButton"; 9import { PublishButton } from "./actions/PublishButton"; 10import { useEntitySetContext } from "components/EntitySetProvider"; 11import { Watermark } from "components/Watermark"; 12import { BackToPubButton } from "./actions/BackToPubButton"; 13import { useLeafletPublicationData } from "components/PageSWRDataProvider"; 14import { useIdentityData } from "components/IdentityProvider"; 15import { useEntity } from "src/replicache"; 16import { block } from "sharp"; 17 18export function hasBlockToolbar(blockType: string | null | undefined) { 19 return ( 20 blockType === "text" || 21 blockType === "heading" || 22 blockType === "blockquote" || 23 blockType === "button" || 24 blockType === "datetime" || 25 blockType === "image" 26 ); 27} 28export function LeafletFooter(props: { entityID: string }) { 29 let focusedBlock = useUIState((s) => s.focusedEntity); 30 31 let entity_set = useEntitySetContext(); 32 let { identity } = useIdentityData(); 33 let { data: pub } = useLeafletPublicationData(); 34 let blockType = useEntity(focusedBlock?.entityID || null, "block/type")?.data 35 .value; 36 37 return ( 38 <Media mobile className="mobileFooter w-full z-10 touch-none -mt-[54px] "> 39 {focusedBlock && 40 focusedBlock.entityType == "block" && 41 hasBlockToolbar(blockType) && 42 entity_set.permissions.write ? ( 43 <div 44 className="w-full z-10 p-2 flex bg-bg-page pwa-padding-bottom" 45 onMouseDown={(e) => { 46 if (e.currentTarget === e.target) e.preventDefault(); 47 }} 48 > 49 <Toolbar 50 pageID={focusedBlock.parent} 51 blockID={focusedBlock.entityID} 52 blockType={blockType} 53 /> 54 </div> 55 ) : entity_set.permissions.write ? ( 56 <ActionFooter> 57 {pub?.publications && 58 identity?.atp_did && 59 pub.publications.identity_did === identity.atp_did ? ( 60 <BackToPubButton publication={pub.publications} /> 61 ) : ( 62 <HomeButton /> 63 )} 64 65 <PublishButton entityID={props.entityID} /> 66 <ShareOptions /> 67 <ThemePopover entityID={props.entityID} /> 68 </ActionFooter> 69 ) : ( 70 <div className="pb-2 px-2 z-10 flex justify-end"> 71 <Watermark mobile /> 72 </div> 73 )} 74 </Media> 75 ); 76}